// main.cpp

#include <iostream>

#include "gmBomb.h"

gmMachine *gm;

int GM_CDECL gmTestFunc( gmThread *a_thread )
{
	bomb *b = gmBomb::GetObject(gm,"test");
	b->explode();
	return GM_OK;
}

int main()
{
	gm = new gmMachine();

	gmBomb::Initialise(gm);
	gm->RegisterLibraryFunction("testFunc", gmTestFunc);

	gm->ExecuteString("global test = bomb(); test.explode(); testFunc(); test.explode();");


	delete gm;

/*    // Create a GameMonkey machine
    gmMachine   *gm = new gmMachine();
    
    // Initialise the 'bomb' type within this gmMachine
    gmBomb::Initialise( gm );
    
    // Create a global bomb object called 'boomer'
    //gmBomb::CreateObject( gm, "boomer" ); 
    gm->ExecuteString( "global boomer = bomb();" );   
    // This object can now be used within your scripts
    //
    // GM Example
    //
    // boomer.explode();        // should go boom!
    // boomer.explode();        // already exploded :(
    // boomer.isExploded = 0;   // Reset the exploded status
    // boomer.explode();        // should go boom again!
    
    // Let's have some fun and claim boomer from the script
    bomb *myBomb = 0;
    // Retrieve native object pointer belonging to boomer
    myBomb = gmBomb::GetObject( gm, "boomer" );
    // Reclaim ownership to the pointer - gmBind will no longer delete it
    gmBomb::OwnObject( gm, "boomer", true );
    
    // myBomb can now persist beyond the script and gmMachine
    // But all this power is scary, give it back to the script
    gmBomb::OwnObject( gm, "boomer", false );
    // We no longer own the pointer to myBomb, so it could be GC'd and deleted
    
    // Let's create an extended property on boomer for fun
    // Create a string property called "MyName" and assign it a value
    gmBomb::SetProperty( gm, "boomer", "MyName", "BOOMER!" );
    
    // Execute a script to display boomer's name
    gm->ExecuteString( "print( `Hello my name is ` + boomer.MyName );" );

    // > Hello my name is BOOMER!

    // Execute another script to change boomer's name
    gm->ExecuteString( "boomer.MyName = `Freddy`;" );
    
    // Execute a script to display boomer's name again
    gm->ExecuteString( "print( `Hello my name is ` + boomer.MyName );" );
    
    // > Hello my name is Freddy
    
    // Let's retreive boomer's name ourselves
    const char *name = 0;
    gmBomb::GetProperty( gm, "boomer", "MyName", name );
    
    // Say his name from the program
    std::cout << "boomer's name is " << name << std::endl;
    
    delete gm;
    
    // Too much fun, bye bye. Don't worry about boomer, he'll be GC'd
    // and his native pointer deleted    
    return 0;  */
}; 
